package com.zhixing.service.executor;

import lombok.Getter;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * swagger Executor 工厂类
 *
 * @author zhixing
 */
public class SwaggerExecutorFactory {

    @Getter
    public static enum SwaggerExecutorType{
        SIMPLE(0),
        OPTIONAL(1)
        ;
        private Integer code;

        SwaggerExecutorType(Integer code) {
            this.code = code;
        }
    }

    /**
     *
     * @param swaggerJsonStr swagger json str
     * @return
     */
    public static SwaggerExecutor getInstance(String swaggerJsonStr){
        return new SimpleSwagger2WordExecutor(swaggerJsonStr);
    }


    /**
     *
     * @param includeTags 需要生成数据的 tags
     * @param swaggerJsonStr swagger json str
     * @return
     */
    public static SwaggerExecutor getInstance(List<String> includeTags,String swaggerJsonStr){
        if(CollectionUtils.isEmpty(includeTags)){
            return SwaggerExecutorFactory.getInstance(swaggerJsonStr);
        }
        return new OptionalSwagger2WordExecutor(swaggerJsonStr,includeTags);
    }
}
